package front_comment_api

import (
	"blog_go/global"
	"blog_go/models"
	"blog_go/models/res"
	"blog_go/service/redis_ser"
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
)

type CommentDiggReq struct {
	ID uint `json:"id"`
}

func (CommentApi) CommentDigg(c *gin.Context) {
	var req CommentDiggReq
	if err := c.ShouldBindJSON(&req); err != nil {
		logrus.Error(err)
		panic(err)
	}
	var comment models.CommentModel
	err := global.DB.First(&comment, req.ID).Error
	if err != nil {
		logrus.Error(err)
		panic(err)
	}
	redis_ser.NewCommentDigg().DiggIncr(req.ID)
	res.OkWithMessage("点赞成功", c)
}
